Call of a strategy within another strategy is not supported directly, howerver, one can instantiate an <i>IStrategy</i> object within his strategy and on call of any of its methods, "forward" the method's parameters to the correspoding method of the object. <br/><div class="dw_article_headers_list"><div class="dw_article_header_h1"><a href="#Multiple_strategies_within_a_strategy/Call_inner_strategy">Call inner strategy</a></div><div class="dw_article_header_h1"><a href="#Multiple_strategies_within_a_strategy/Call_strategy_from_a_jar_file">Call strategy from a jar file</a></div><div class="dw_article_header_h1"><a href="#Multiple_strategies_within_a_strategy/Managing_multiple_strategy_instances_from_a_tab/window">Managing multiple strategy instances from a tab/window</a></div><div class="dw_article_header_h2"><a href="#Multiple_strategies_within_a_strategy/Running_the_sample_strategy">Running the sample strategy</a></div><div class="dw_article_header_h2"><a href="#Multiple_strategies_within_a_strategy/The_source_code">The source code</a></div></div><span id="Multiple_strategies_within_a_strategy/Call_inner_strategy"><h1>Call inner strategy</h1></span>Consider adding another strategy class <i>InnerStrategy</i> in the same java file and creating 2 strategy instances in <i>ParallelInnerStrategyCalls </i>.  Then at each call of any of <i>ParallelInnerStrategyCalls</i> methods, their parameters get forwarded to <i>InnerStrategy</i> objects.<br/><div class="dw_article_geshi_code"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">jforex.strategies</span><span style="color: #339933;">;</span><br /><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.UUID</span><span style="color: #339933;">;</span><br /><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dukascopy.api.*</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dukascopy.api.IEngine.OrderCommand</span><span style="color: #339933;">;</span><br /><br /><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ParallelInnerStrategyCalls <span style="color: #000000; font-weight: bold;">implements</span> IStrategy <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> InnerStrategy strategy1<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> InnerStrategy strategy2<span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStart<span style="color: #009900;">&#40;</span>IContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> InnerStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">prefix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;strat5pip_&quot;</span><span style="color: #339933;">;</span> &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">amount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.01</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">stopLossPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">takeProfitPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> InnerStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">prefix</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;strat10pip_&quot;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">amount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.02</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">stopLossPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">takeProfitPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onStart</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onStart</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTick<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, ITick tick<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onTick</span><span style="color: #009900;">&#40;</span>instrument, tick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onTick</span><span style="color: #009900;">&#40;</span>instrument, tick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onBar<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, Period period, IBar askBar, IBar bidBar<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onBar</span><span style="color: #009900;">&#40;</span>instrument, period, askBar, bidBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onBar</span><span style="color: #009900;">&#40;</span>instrument, period, askBar, bidBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onMessage<span style="color: #009900;">&#40;</span>IMessage message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onMessage</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onMessage</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onAccount<span style="color: #009900;">&#40;</span>IAccount account<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onAccount</span><span style="color: #009900;">&#40;</span>account<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onAccount</span><span style="color: #009900;">&#40;</span>account<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onStop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onStop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br /><span style="color: #009900;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> InnerStrategy <span style="color: #000000; font-weight: bold;">implements</span> IStrategy <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Configurable parameters</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prefix&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> prefix <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;strat_&quot;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Instrument&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Instrument</span> instrument <span style="color: #339933;">=</span> <span style="color: #003399;">Instrument</span>.<span style="color: #006633;">EURUSD</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Amount&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> amount <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.02</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Stop loss&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> stopLossPips <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Take profit&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> takeProfitPips <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IEngine engine<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IConsole console<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IHistory history<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStart<span style="color: #009900;">&#40;</span>IContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">engine</span> <span style="color: #339933;">=</span> context.<span style="color: #006633;">getEngine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">console</span> <span style="color: #339933;">=</span> context.<span style="color: #006633;">getConsole</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">history</span> <span style="color: #339933;">=</span> context.<span style="color: #006633;">getHistory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006633;">getOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;started inner strategy: &quot;</span> <span style="color: #339933;">+</span> instrument <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> amount <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> stopLossPips<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">double</span> price <span style="color: #339933;">=</span> history.<span style="color: #006633;">getLastTick</span><span style="color: #009900;">&#40;</span>instrument<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getBid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> label <span style="color: #339933;">=</span> prefix <span style="color: #339933;">+</span> UUID.<span style="color: #006633;">randomUUID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; engine.<span style="color: #006633;">submitOrder</span><span style="color: #009900;">&#40;</span>label, instrument, OrderCommand.<span style="color: #006633;">BUY</span>, amount, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">20</span>, <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; price <span style="color: #339933;">-</span> stopLossPips <span style="color: #339933;">*</span> instrument.<span style="color: #006633;">getPipValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; price <span style="color: #339933;">+</span> takeProfitPips <span style="color: #339933;">*</span> instrument.<span style="color: #006633;">getPipValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTick<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, ITick tick<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onBar<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, Period period, IBar askBar,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IBar bidBar<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onMessage<span style="color: #009900;">&#40;</span>IMessage message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; IOrder order <span style="color: #339933;">=</span> message.<span style="color: #006633;">getOrder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//print messages only of our order</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>order <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> order.<span style="color: #006633;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span>prefix<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006633;">getOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>message.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onAccount<span style="color: #009900;">&#40;</span>IAccount account<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>IOrder order <span style="color: #339933;">:</span> engine.<span style="color: #006633;">getOrders</span><span style="color: #009900;">&#40;</span>instrument<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>order.<span style="color: #006633;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span>prefix<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; order.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br /><span style="color: #009900;">&#125;</span><br /></div><span id="Multiple_strategies_within_a_strategy/Call_strategy_from_a_jar_file"><h1>Call strategy from a jar file</h1></span>In the given example <i>StrategySimpleParallel</i> class holds two instances of <a href="#Simple_Strategy">Simple Strategy</a> as fields. At each call of any of <i>StrategySimpleParallel</i> methods, their parameters get forwarded to <i>SimpleStrategy</i> objects.<br/><div class="dw_article_geshi_code"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">jforex.strategies</span><span style="color: #339933;">;</span><br /><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dukascopy.api.*</span><span style="color: #339933;">;</span><br /><br /><span style="color: #666666; font-style: italic;">//SimpleStrategy is located in a jar file</span><br />@RequiresFullAccess<br />@Library<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;C:/temp/simple-strategies.jar&quot;</span><span style="color: #009900;">&#41;</span><br /><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StrategySimpleParallel <span style="color: #000000; font-weight: bold;">implements</span> IStrategy <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IStrategy strategy1<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IStrategy strategy2<span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStart<span style="color: #009900;">&#40;</span>IContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SimpleStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//different configuration for each of the strategies</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SimpleStrategy<span style="color: #009900;">&#41;</span>strategy1<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">amount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.001</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SimpleStrategy<span style="color: #009900;">&#41;</span>strategy1<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">stopLossPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">40</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SimpleStrategy<span style="color: #009900;">&#41;</span>strategy1<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">takeProfitPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">40</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SimpleStrategy<span style="color: #009900;">&#41;</span>strategy2<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">amount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.002</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SimpleStrategy<span style="color: #009900;">&#41;</span>strategy2<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">stopLossPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>SimpleStrategy<span style="color: #009900;">&#41;</span>strategy2<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">takeProfitPips</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//forwarding of parameters&nbsp; &nbsp; &nbsp; </span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onStart</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onStart</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTick<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, ITick tick<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//forwarding of parameters</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onTick</span><span style="color: #009900;">&#40;</span>instrument, tick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onTick</span><span style="color: #009900;">&#40;</span>instrument, tick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onBar<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, Period period, IBar askBar, IBar bidBar<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onBar</span><span style="color: #009900;">&#40;</span>instrument, period, askBar, bidBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onBar</span><span style="color: #009900;">&#40;</span>instrument, period, askBar, bidBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onMessage<span style="color: #009900;">&#40;</span>IMessage message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onMessage</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onMessage</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onAccount<span style="color: #009900;">&#40;</span>IAccount account<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onAccount</span><span style="color: #009900;">&#40;</span>account<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onAccount</span><span style="color: #009900;">&#40;</span>account<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy1.<span style="color: #006633;">onStop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy2.<span style="color: #006633;">onStop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br /><span style="color: #009900;">&#125;</span></div>In order to ensure universal label uniqueness between both of the launched strategies one should change the <i>getLabel</i> method of <i>SimpleStrategy</i>.<br/><div class="dw_article_geshi_code"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> getLabel<span style="color: #009900;">&#40;</span>OrderCommand cmd<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> cmd.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> UUID.<span style="color: #006633;">randomUUID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</span>, <span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><span style="color: #009900;">&#125;</span></div><a href="https://www.dukascopy.com/wiki/files//StrategySimpleParallel.java">StrategySimpleParallel.java</a><br/><span id="Multiple_strategies_within_a_strategy/Managing_multiple_strategy_instances_from_a_tab/window"><h1>Managing multiple strategy instances from a tab/window</h1></span>Consider a strategy which allows the user to conveniently run and manage multiple strategies from a platform tab. The advantage of this approach is that one can see all parameters of all launched strategy intstances and manage the collection of launched strategies - save strategy parameter configurations, add or remove strategies from the list, start all strategies, and change parameters while the concrete strategy is in a running state. If the users changes a paramter in the strtegy table, the changes immediately affects the running strategy - the strategy from then on works with the new parameter value.<br/><hr><span id="Multiple_strategies_within_a_strategy/Running_the_sample_strategy"><h2>Running the sample strategy</h2></span>Consider the following steps:<br/><ul><li>Download <a href="https://www.dukascopy.com/wiki/files//MultistrategiesTest.java">MultistrategiesTest.java</a>.</li><li>Open the strategy in <i>jForex</i> platform, <u>locate the InnerStrategy class</u> in the MultistrategiesTest.java and <u>replace its contents with the contents of your strategy class contents</u> (don't change the <i>InnerStrategy</i> strategy name).</li><li>Compile and run the strategy.</li><li><i>Define Parameters</i> dialog gets opened. By default the <i>Strategy Configuration</i> is opened in a new tab of the <i>jForex</i> platform. If one deselects <i>Show "Strategy Properties" as tab</i>, then the table of strategies gets opened in new window. <i>Start immediately</i> option works only if one indicates <i>Choose property xml file</i>. If selected, then all strategies are started immediately. Choose <i>Run</i>. <br> <img src="https://www.dukascopy.com/wiki/files//001_MultistrategiesTest_001.png" border="0" /> <br></li><li>A new tab (<i>Strategy Configuration</i>) gets opened in the <i>jForex</i> platform <br> <img src="https://www.dukascopy.com/wiki/files//001_MultistrategiesTest_002.png" border="0" /></li><li>Add some additional strategies to the table by pressing <i>Add Strategy</i> button.</li><li>If one wants to remove some strategies from the list, then he needs to select them by holding the <i>Ctrl</i> button and press <i>Remove Selected</i> button. <br> <img src="https://www.dukascopy.com/wiki/files//001_MultistrategiesTest_004.png" border="0" /></li><li>Modify the settings of the strategies. <br> <img src="https://www.dukascopy.com/wiki/files//001_MultistrategiesTest_005.png" border="0" /></li><li>Press <i>Save</i> button to save the configuration of the strategies as an <i>xml</i> file for later use. Name the file and save it on the local file system.</li><li>Press <i>Start</i> button to start all strategies.</li><li>Consider, that the logging information is printed only for these strategies which has a <i>Logg 10 Second Bar Values</i> of true.</li><li>Change some parameters - e.g. deselect the <i>Logg 10 Second Bar Values</i> check-box. Now the log is not printed. The changes takes place immediately as the table cells are modified.</li><li>Now close the strategy by right-clicking the strategy's node in <i>jForex</i> and choosing <i>Stop</i>. The <i>Strategies Configuration</i> tab/window is closed automatically.</li><li>Run the strategy again. At this time, indicate for the saved file in <i>Choose property xml file</i> property and deselect the <i>Show "Strategy Properties" as tab</i>. <br> <img src="https://www.dukascopy.com/wiki/files//001_MultistrategiesTest_007.png" border="0" /></li><li>Press <i>Run</i>. Consider that the previously saved strategies are opened with the saved parameters in a new window. Press <i>Start</i> button to start the strategies. <br> <img src="https://www.dukascopy.com/wiki/files//001_MultistrategiesTest_008.png" border="0" /></li></ul><span id="Multiple_strategies_within_a_strategy/The_source_code"><h2>The source code</h2></span>Some notes about this example:<br/><ul><li>The code is written to work with a client strategy which uses parameters of the following types of objects and java primitives: <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Enum.html"><i>Enum</i></a> (e.g. <a href="http://www.dukascopy.com/client/javadoc/com/dukascopy/api/Instrument.html"><i>Instrument</i></a>, <a href="http://www.dukascopy.com/client/javadoc/com/dukascopy/api/OfferSide.html"><i>OfferSide</i></a>), <a href="http://www.dukascopy.com/client/javadoc/com/dukascopy/api/Period.html"><i>Period</i></a>, <a href="http://docs.oracle.com/javase/6/docs/api/javax/lang/model/type/PrimitiveType.html"><i>double, boolean, int</i></a>, <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/String.html"><i>String</i></a>.</li><li>The code adds instance variables of the client strategy to the table only if the variable is identified with the <a href="http://www.dukascopy.com/client/javadoc/com/dukascopy/api/Configurable.html"><i>@Configurable</i></a> annotation.</li><li>The table of strategies adds drop-down lists only for <i>Enum</i> and <i>Period</i> property data types.</li><li>Code does not validate changed data in the table of strategies (e.g. one can easy set <a href="#Set_Stop_Loss_price">Stop-Loss value</a> for -100000).</li><li>If the client's strategy works with specific instruments, then don't forget to <a href="#Subscribe_to_an_instrument">subscribe them</a> before launching the strategy. If one changes the instrument type in the table of strategies, then he needs to check whether he has subscribed for this type of the instrument.</li><li>Defined instance parameters (specified with <a href="http://www.dukascopy.com/client/javadoc/com/dukascopy/api/Configurable.html"><i>@Configurable</i></a> annotation) of client strategy must be initialized with default values at the declaration time.</li></ul>Here is the code of the strategy including the client's sample strategy (<i>InnerStrategy</i>):<br/><div class="dw_article_geshi_code"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">multistrat</span><span style="color: #339933;">;</span><br /><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.dukascopy.api.*</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.BorderLayout</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Container</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Dimension</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Toolkit</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.ActionEvent</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.ActionListener</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.PrintWriter</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.lang.reflect.Field</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collection</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashSet</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Set</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.DefaultCellEditor</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JButton</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JComboBox</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JFileChooser</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JFrame</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JOptionPane</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JPanel</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JScrollPane</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JTable</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.event.TableModelEvent</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.filechooser.FileFilter</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.filechooser.FileNameExtensionFilter</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.table.AbstractTableModel</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.table.DefaultTableCellRenderer</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.parsers.DocumentBuilder</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.parsers.DocumentBuilderFactory</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.OutputKeys</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.Transformer</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.TransformerFactory</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.dom.DOMSource</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.transform.stream.StreamResult</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.w3c.dom.Document</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.w3c.dom.Element</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.w3c.dom.Node</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.w3c.dom.NodeList</span><span style="color: #339933;">;</span><br /><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.w3c.dom.Text</span><span style="color: #339933;">;</span><br /><br />@RequiresFullAccess<br /><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MultistrategiesTest <span style="color: #000000; font-weight: bold;">implements</span> IStrategy <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*define and create a list which will hold all strategies of JTable. <br />&nbsp; &nbsp; &nbsp;* If one loads a new strategy configuration file (xml), the strategy <br />&nbsp; &nbsp; &nbsp;* objects are created from xml data and stored in this list<br />&nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>InnerStrategy<span style="color: #339933;">&gt;</span> strategiesList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>InnerStrategy<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//define variables for GUI</span><br />&nbsp; &nbsp; <span style="color: #003399;">JTable</span> table<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #003399;">JFrame</span> frame<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #003399;">JScrollPane</span> scrollPane<span style="color: #339933;">;</span><br />&nbsp; &nbsp; MyTableModel tableModel<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> TAB_KEY <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Strategies Configuration&quot;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> onStartStarted <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//strategy variables</span><br />&nbsp; &nbsp; IContext context<span style="color: #339933;">;</span><br />&nbsp; &nbsp; IConsole console<span style="color: #339933;">;</span><br />&nbsp; &nbsp; IUserInterface userInterface<span style="color: #339933;">;</span><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp;* At the main strategy's startup there will be properties indicating <br />&nbsp; &nbsp; &nbsp;* several options.<br />&nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Choose property xml file: &quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">File</span> propertyFile<span style="color: #339933;">;</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Start immediately&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> startImmediately <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Show <span style="color: #000099; font-weight: bold;">\\&quot;</span>Strategy Properties<span style="color: #000099; font-weight: bold;">\\&quot;</span> as tab&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> showAsTab <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp;* The main strategy's onStart method initializes variables, <br />&nbsp; &nbsp; &nbsp;* plus creates a GUI according to given prameters<br />&nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStart<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> IContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">context</span> <span style="color: #339933;">=</span> context<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">console</span> <span style="color: #339933;">=</span> context.<span style="color: #006633;">getConsole</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userInterface</span> <span style="color: #339933;">=</span> context.<span style="color: #006633;">getUserInterface</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/* if a xml file is chosen, then check the file and create IStrategy objects according <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* to xml fields. Add strategy objects to the list of the strategies. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* else - create default IStrategy object with default values and add to list of strategies. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>propertyFile <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">&quot;&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>propertyFile.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> propertyFile.<span style="color: #006633;">isFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>propertyFile.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.xml&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> propertyFile.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.XML&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//read strategies and add to the list</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; readStrategiesFromXML<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategiesList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> InnerStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Table model is created according to list of strategies. It is important <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* to create a table model after the list of strategies is filled. Next, create a table<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* and add it to scroll pane. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; tableModel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyTableModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; table <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JTable</span><span style="color: #009900;">&#40;</span>tableModel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: #006633;">setPreferredScrollableViewportSize</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Dimension</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span>, <span style="color: #cc66cc;">70</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: #006633;">setFillsViewportHeight</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; scrollPane <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JScrollPane</span><span style="color: #009900;">&#40;</span>table<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* create jForex platforms tab of new JFrame according to user's choice. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* If user has chosen to start immediately, then disable buttons &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">SwingUtilities</span>.<span style="color: #006633;">invokeLater</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Runnable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MyPanel myPanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyPanel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>startImmediately<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myPanel.<span style="color: #006633;">disableButtons</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Container</span> content <span style="color: #339933;">=</span> myPanel.<span style="color: #006633;">createAndShowGUI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* if user has choosed to show as tab, create tab, else - <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* create a JFrame. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>showAsTab<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JPanel</span> panel <span style="color: #339933;">=</span> userInterface.<span style="color: #006633;">getBottomTab</span><span style="color: #009900;">&#40;</span>TAB_KEY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; panel.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BorderLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>content, <span style="color: #003399;">BorderLayout</span>.<span style="color: #006633;">CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JFrame</span><span style="color: #009900;">&#40;</span>TAB_KEY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setContentPane</span><span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setDefaultCloseOperation</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">JFrame</span>.<span style="color: #006633;">HIDE_ON_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">pack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//get the dimensions of the screen</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Dimension</span> dim <span style="color: #339933;">=</span> <span style="color: #003399;">Toolkit</span>.<span style="color: #006633;">getDefaultToolkit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getScreenSize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setSize</span><span style="color: #009900;">&#40;</span>dim.<span style="color: #006633;">width</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, dim.<span style="color: #006633;">height</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Determine the new location of the window &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>dim.<span style="color: #006633;">width</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> frame.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>dim.<span style="color: #006633;">height</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">-</span> frame.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setLocation</span><span style="color: #009900;">&#40;</span>x, y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> exception<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exception.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* If startImmediately is true, check whether the configuration xml file is given. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* If not, show error message. If the file is given, then start all strategies of the list <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>startImmediately <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>propertyFile <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">&quot;&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>propertyFile.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> propertyFile.<span style="color: #006633;">isFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>propertyFile.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.xml&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> propertyFile.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">endsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.XML&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onStart</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onStartStarted <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> exception<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exception.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;A file of strategy properties is not specified! &quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;One cannot select <span style="color: #000099; font-weight: bold;">\\&quot;</span>Start Immediately<span style="color: #000099; font-weight: bold;">\\&quot;</span> without specifying the xml file of properties.&quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\n</span>If choosed to <span style="color: #000099; font-weight: bold;">\\&quot;</span>Start Immediately<span style="color: #000099; font-weight: bold;">\\&quot;</span> then rerun the strategy and specify a &quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;xml file of strategy properties&quot;</span>, <span style="color: #0000ff;">&quot;Properties File Not Found&quot;</span>, <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">ERROR_MESSAGE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; userInterface.<span style="color: #006633;">removeBottomTab</span><span style="color: #009900;">&#40;</span>TAB_KEY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>frame <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of the onStart method</span><br /><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp;* method, which reads xml file by using jaxp-dom technique. <br />&nbsp; &nbsp; &nbsp;* Method creates a new strategy object and then replaces the default values with<br />&nbsp; &nbsp; &nbsp;* values of xml file. This strategy works only with following parameter types:<br />&nbsp; &nbsp; &nbsp;* enums, Period, double, boolean, String, int. If one wants to work with different<br />&nbsp; &nbsp; &nbsp;* ones, then he needs to modify the code of this method. <br />&nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> readStrategiesFromXML<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DocumentBuilderFactory documentBuilderFactory <span style="color: #339933;">=</span> DocumentBuilderFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DocumentBuilder documentBuilder <span style="color: #339933;">=</span> documentBuilderFactory.<span style="color: #006633;">newDocumentBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Document</span> document <span style="color: #339933;">=</span> documentBuilder.<span style="color: #006633;">parse</span><span style="color: #009900;">&#40;</span>propertyFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.<span style="color: #006633;">getDocumentElement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">normalize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NodeList strategyElementList <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Strategy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//for each strategy Node add new Strategy to strategy list and get NodeList of elements and iterate through</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> x <span style="color: #339933;">&lt;</span> strategyElementList.<span style="color: #006633;">getLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> x<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//add new strategy to list</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InnerStrategy myCurrentStrategy <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> InnerStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategiesList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>myCurrentStrategy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//get child elements:</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NodeList strategyNodeList <span style="color: #339933;">=</span> strategyElementList.<span style="color: #006633;">item</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getChildNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> y <span style="color: #339933;">&lt;</span> strategyNodeList.<span style="color: #006633;">getLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> y<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>strategyNodeList.<span style="color: #006633;">item</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getNodeType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> Node.<span style="color: #006633;">ELEMENT_NODE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Element</span> parameterElement <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Element</span><span style="color: #009900;">&#41;</span> strategyNodeList.<span style="color: #006633;">item</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> variableName <span style="color: #339933;">=</span> parameterElement.<span style="color: #006633;">getNodeName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> nodeValue <span style="color: #339933;">=</span> parameterElement.<span style="color: #006633;">getTextContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Field</span> field <span style="color: #339933;">=</span> myCurrentStrategy.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getField</span><span style="color: #009900;">&#40;</span>variableName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Class<span style="color: #339933;">&lt;?&gt;</span> clazz <span style="color: #339933;">=</span> field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isEnum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> valueEnum <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>nodeValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> enums <span style="color: #339933;">=</span> field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getEnumConstants</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>myCurrentStrategy, enums<span style="color: #009900;">&#91;</span>valueEnum<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> Period.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Period newPeriod <span style="color: #339933;">=</span> Period.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>nodeValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>myCurrentStrategy, newPeriod<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">double</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">double</span> newDouble <span style="color: #339933;">=</span> <span style="color: #003399;">Double</span>.<span style="color: #006633;">parseDouble</span><span style="color: #009900;">&#40;</span>nodeValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>myCurrentStrategy, newDouble<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">boolean</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> newBoolean <span style="color: #339933;">=</span> <span style="color: #003399;">Boolean</span>.<span style="color: #006633;">parseBoolean</span><span style="color: #009900;">&#40;</span>nodeValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>myCurrentStrategy, newBoolean<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>myCurrentStrategy, nodeValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">int</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> newInt <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>nodeValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; field.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>myCurrentStrategy, newInt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">IllegalArgumentException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Parameter's type not supported. Required &quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;Instrument/Period/OfferSide/String/boolean/double/int, found: &quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> myCurrentStrategy.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getField</span><span style="color: #009900;">&#40;</span>variableName<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of method readStrategiesFromXML</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTick<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, ITick tick<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>onStartStarted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onTick</span><span style="color: #009900;">&#40;</span>instrument, tick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onBar<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, Period period, IBar askBar, IBar bidBar<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>onStartStarted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onBar</span><span style="color: #009900;">&#40;</span>instrument, period, askBar, bidBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onMessage<span style="color: #009900;">&#40;</span>IMessage message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>onStartStarted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onMessage</span><span style="color: #009900;">&#40;</span>message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onAccount<span style="color: #009900;">&#40;</span>IAccount account<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>onStartStarted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onAccount</span><span style="color: #009900;">&#40;</span>account<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//close the tab/frame when strategy is stopped</span><br />&nbsp; &nbsp; @Override<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>onStartStarted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onStop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; userInterface.<span style="color: #006633;">removeBottomTab</span><span style="color: #009900;">&#40;</span>TAB_KEY<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>frame <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; frame.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp;* A class which creates a content pane for <br />&nbsp; &nbsp; &nbsp;* tab/frame. Here are defined all elements and actions.<br />&nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> MyPanel <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JPanel</span> mainPanel <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JButton</span> addButton <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Add Strategy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JButton</span> startButton <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Start&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JButton</span> saveButton <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Save&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JButton</span> removeButton <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JButton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Remove Selected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> disableButtons<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removeButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; saveButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">JPanel</span> createAndShowGUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategiesList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> InnerStrategy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tableModel.<span style="color: #006633;">fireTableChanged</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TableModelEvent</span><span style="color: #009900;">&#40;</span>tableModel<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategy.<span style="color: #006633;">onStart</span><span style="color: #009900;">&#40;</span>context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onStartStarted <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; startButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; saveButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removeButton.<span style="color: #006633;">setEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> exception<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exception.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>onStartStarted<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006633;">getNotif</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Strategy/ies started!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006633;">getErr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error while starting strategies!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Save the configurations of strategies in a xml file by using <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* jaxp-dom technique. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; saveButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Create Document</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DocumentBuilderFactory docBuildFacrotry <span style="color: #339933;">=</span> DocumentBuilderFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DocumentBuilder docBuilder <span style="color: #339933;">=</span> docBuildFacrotry.<span style="color: #006633;">newDocumentBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Document</span> document <span style="color: #339933;">=</span> docBuilder.<span style="color: #006633;">newDocument</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//create elements and add to document</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Element</span> strategiesNode <span style="color: #339933;">=</span> document.<span style="color: #006633;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Strategies&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document.<span style="color: #006633;">appendChild</span><span style="color: #009900;">&#40;</span>strategiesNode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>IStrategy strategy <span style="color: #339933;">:</span> strategiesList<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//create strategy element and add</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Element</span> strategyNode <span style="color: #339933;">=</span> document.<span style="color: #006633;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Strategy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategiesNode.<span style="color: #006633;">appendChild</span><span style="color: #009900;">&#40;</span>strategyNode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Field</span> field <span style="color: #339933;">:</span> strategy.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getFields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getAnnotation</span><span style="color: #009900;">&#40;</span>Configurable.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Element</span> element <span style="color: #339933;">=</span> document.<span style="color: #006633;">createElement</span><span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text textValue<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isEnum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textValue <span style="color: #339933;">=</span> document.<span style="color: #006633;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Enum<span style="color: #339933;">&lt;?&gt;</span><span style="color: #009900;">&#41;</span> field.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>strategy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">ordinal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textValue <span style="color: #339933;">=</span> document.<span style="color: #006633;">createTextNode</span><span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>strategy<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> Period.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; textValue <span style="color: #339933;">=</span> document.<span style="color: #006633;">createTextNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Period<span style="color: #009900;">&#41;</span> field.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>strategy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; element.<span style="color: #006633;">appendChild</span><span style="color: #009900;">&#40;</span>textValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategyNode.<span style="color: #006633;">appendChild</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//write to file:</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransformerFactory transformerFactory <span style="color: #339933;">=</span> TransformerFactory.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Transformer transformer <span style="color: #339933;">=</span> transformerFactory.<span style="color: #006633;">newTransformer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; transformer.<span style="color: #006633;">setOutputProperty</span><span style="color: #009900;">&#40;</span>OutputKeys.<span style="color: #006633;">INDENT</span>, <span style="color: #0000ff;">&quot;yes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JFileChooser</span> fileChooser <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JFileChooser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">FileFilter</span> filter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileNameExtensionFilter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;XML file&quot;</span>, <span style="color: #0000ff;">&quot;xml&quot;</span>, <span style="color: #0000ff;">&quot;XML&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fileChooser.<span style="color: #006633;">setFileFilter</span><span style="color: #009900;">&#40;</span>filter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> returnVal <span style="color: #339933;">=</span> fileChooser.<span style="color: #006633;">showSaveDialog</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>returnVal <span style="color: #339933;">==</span> <span style="color: #003399;">JFileChooser</span>.<span style="color: #006633;">APPROVE_OPTION</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>fileChooser.<span style="color: #006633;">getSelectedFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">File</span> file <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>fileChooser.<span style="color: #006633;">getSelectedFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.xml&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">PrintWriter</span> printWriter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">PrintWriter</span><span style="color: #009900;">&#40;</span>file<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StreamResult result <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StreamResult<span style="color: #009900;">&#40;</span>printWriter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DOMSource source <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMSource<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; transformer.<span style="color: #006633;">transform</span><span style="color: #009900;">&#40;</span>source, result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JOptionPane</span>.<span style="color: #006633;">showMessageDialog</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #0000ff;">&quot;File saved successfully!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printWriter.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> exception<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exception.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; removeButton.<span style="color: #006633;">addActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ActionListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> selectedRows <span style="color: #339933;">=</span> table.<span style="color: #006633;">getSelectedRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Collection<span style="color: #339933;">&lt;</span>IStrategy<span style="color: #339933;">&gt;</span> collectionToRemove <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>IStrategy<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">:</span> selectedRows<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; collectionToRemove.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategiesList.<span style="color: #006633;">removeAll</span><span style="color: #009900;">&#40;</span>collectionToRemove<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tableModel.<span style="color: #006633;">fireTableChanged</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">TableModelEvent</span><span style="color: #009900;">&#40;</span>tableModel<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//call for table column renderer</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setUpColumns<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainPanel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span> layout <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span><span style="color: #009900;">&#40;</span>mainPanel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainPanel.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span>layout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.<span style="color: #006633;">setHorizontalGroup</span><span style="color: #009900;">&#40;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">TRAILING</span>, layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>saveButton<span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>removeButton<span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>addButton<span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>startButton<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>scrollPane<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.<span style="color: #006633;">setVerticalGroup</span><span style="color: #009900;">&#40;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">LEADING</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>layout.<span style="color: #006633;">createSequentialGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addGroup</span><span style="color: #009900;">&#40;</span>layout.<span style="color: #006633;">createParallelGroup</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #006633;">GroupLayout</span>.<span style="color: #006633;">Alignment</span>.<span style="color: #006633;">BASELINE</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>saveButton<span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>removeButton<span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>addButton<span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>startButton<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>scrollPane<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.<span style="color: #006633;">setAutoCreateContainerGaps</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; layout.<span style="color: #006633;">setAutoCreateGaps</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mainPanel.<span style="color: #006633;">setOpaque</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//content panes must be opaque</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> mainPanel<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* The columns of jtable is created so that the enum values and Period values<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* are created as drop-down lists (JComboBox). If one wants to add another type<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* of elements, he needs to do it here. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> setUpColumns<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> table.<span style="color: #006633;">getColumnCount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getColumnClass</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isEnum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JComboBox</span> comboBox <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JComboBox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> object <span style="color: #339933;">:</span> table.<span style="color: #006633;">getColumnClass</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getEnumConstants</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; comboBox.<span style="color: #006633;">addItem</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: #006633;">getColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getColumn</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellEditor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DefaultCellEditor</span><span style="color: #009900;">&#40;</span>comboBox<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">DefaultTableCellRenderer</span> renderer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DefaultTableCellRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderer.<span style="color: #006633;">setToolTipText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Click to choose an &quot;</span> <span style="color: #339933;">+</span> table.<span style="color: #006633;">getColumnClass</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: #006633;">getColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getColumn</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellRenderer</span><span style="color: #009900;">&#40;</span>renderer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>table.<span style="color: #006633;">getColumnClass</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> Period.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">JComboBox</span> comboBox <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">JComboBox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Period period <span style="color: #339933;">:</span> Period.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; comboBox.<span style="color: #006633;">addItem</span><span style="color: #009900;">&#40;</span>period<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: #006633;">getColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getColumn</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellEditor</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DefaultCellEditor</span><span style="color: #009900;">&#40;</span>comboBox<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">DefaultTableCellRenderer</span> renderer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DefaultTableCellRenderer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; renderer.<span style="color: #006633;">setToolTipText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Click to choose a Period&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: #006633;">getColumnModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getColumn</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setCellRenderer</span><span style="color: #009900;">&#40;</span>renderer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">continue</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of outer for</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of method setUpColumns</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of inner class MyPanel</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp;* Class which creates table data. <br />&nbsp; &nbsp; &nbsp;*/</span><br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> MyTableModel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">AbstractTableModel</span> <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> columnNames <span style="color: #339933;">=</span> getColNames<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> columnLabels <span style="color: #339933;">=</span> getColLabels<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getColNames<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> names <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Field</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> fields <span style="color: #339933;">=</span> strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getFields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Field</span> field <span style="color: #339933;">:</span> fields<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Configurable parameter <span style="color: #339933;">=</span> field.<span style="color: #006633;">getAnnotation</span><span style="color: #009900;">&#40;</span>Configurable.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parameter <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; names.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>field.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> names.<span style="color: #006633;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> getColLabels<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> labels <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">Field</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> fields <span style="color: #339933;">=</span> strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getFields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Field</span> field <span style="color: #339933;">:</span> fields<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Configurable parameter <span style="color: #339933;">=</span> field.<span style="color: #006633;">getAnnotation</span><span style="color: #009900;">&#40;</span>Configurable.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parameter <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> label <span style="color: #339933;">=</span> parameter.<span style="color: #006633;">value</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>label <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #0000ff;">&quot;&quot;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>label<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label <span style="color: #339933;">=</span> field.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; labels.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>label<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> labels.<span style="color: #006633;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getColumnCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> columnNames.<span style="color: #006633;">length</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> getRowCount<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> strategiesList.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getColumnName<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> col<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> columnLabels<span style="color: #009900;">&#91;</span>col<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> getValueAt<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> row, <span style="color: #000066; font-weight: bold;">int</span> col<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//return data[row][col];</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getField</span><span style="color: #009900;">&#40;</span>columnNames<span style="color: #009900;">&#91;</span>col<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* This method is required to show e.g. check-boxes instead of simple 'true/false' text<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* if the value is boolean. <br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">Class</span> getColumnClass<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getField</span><span style="color: #009900;">&#40;</span>columnNames<span style="color: #009900;">&#91;</span>c<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> isCellEditable<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> row, <span style="color: #000066; font-weight: bold;">int</span> col<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setValueAt<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> value, <span style="color: #000066; font-weight: bold;">int</span> row, <span style="color: #000066; font-weight: bold;">int</span> col<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getField</span><span style="color: #009900;">&#40;</span>columnNames<span style="color: #009900;">&#91;</span>col<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>strategiesList.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span>, value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fireTableCellUpdated<span style="color: #009900;">&#40;</span>row, col<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of class MyTableModel</span><br /><br />&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">/*<br />&nbsp; &nbsp; &nbsp;* Here one needs to implement his strategy which will be added<br />&nbsp; &nbsp; &nbsp;* to the table of strategies. Simply replace the demo strategy <br />&nbsp; &nbsp; &nbsp;* code with another. <br />&nbsp; &nbsp; &nbsp;*/</span> &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">class</span> InnerStrategy <span style="color: #000000; font-weight: bold;">implements</span> IStrategy <span style="color: #009900;">&#123;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IContext context<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> IConsole console<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Instrument&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Instrument</span> instrument <span style="color: #339933;">=</span> <span style="color: #003399;">Instrument</span>.<span style="color: #006633;">EURUSD</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Period&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Period period <span style="color: #339933;">=</span> Period.<span style="color: #006633;">ONE_HOUR</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Offer Side&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> OfferSide offerSide <span style="color: #339933;">=</span> OfferSide.<span style="color: #006633;">BID</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Strop Loss In Pips&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> stopLoss <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5.0</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Logg 10 Second Bar Values&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> logBars <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; @Configurable<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Order Prefix&quot;</span><span style="color: #009900;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> orderPrefix <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;OrderPrefix&quot;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStart<span style="color: #009900;">&#40;</span>IContext context<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">context</span> <span style="color: #339933;">=</span> context<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">console</span> <span style="color: #339933;">=</span> context.<span style="color: #006633;">getConsole</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006633;">getOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OnStart method called: %s, %s, %s, %s, %s, %s&quot;</span>, instrument, period, offerSide, stopLoss, logBars, orderPrefix<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set<span style="color: #339933;">&lt;</span>Instrument<span style="color: #339933;">&gt;</span> instruments <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashSet<span style="color: #339933;">&lt;</span>Instrument<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; instruments.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>instrument<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">setSubscribedInstruments</span><span style="color: #009900;">&#40;</span>instruments, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onTick<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, ITick tick<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onBar<span style="color: #009900;">&#40;</span><span style="color: #003399;">Instrument</span> instrument, Period period, IBar askBar, IBar bidBar<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//filter out 10 second bars and required instrument: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>logBars <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">false</span> <span style="color: #339933;">||</span> period <span style="color: #339933;">!=</span> Period.<span style="color: #006633;">TEN_SECS</span> <span style="color: #339933;">||</span> instrument <span style="color: #339933;">!=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">instrument</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IBar bar <span style="color: #339933;">=</span> offerSide <span style="color: #339933;">==</span> OfferSide.<span style="color: #006633;">ASK</span> <span style="color: #339933;">?</span> askBar <span style="color: #339933;">:</span> bidBar<span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #006633;">getOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;OnBar method called: %s, %s, %s, %s, %s, %s&quot;</span>, instrument, period, offerSide, stopLoss, logBars, orderPrefix<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//console.getOut().println(&quot;------------ -->&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &nbsp; &nbsp; &nbsp;&quot; + instrument + bar);</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onMessage<span style="color: #009900;">&#40;</span>IMessage message<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onAccount<span style="color: #009900;">&#40;</span>IAccount account<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> JFException <span style="color: #009900;">&#123;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br /><span style="color: #009900;">&#125;</span><br /></div>  